package com.wxl.common.room.dao

import androidx.room.*
import com.wxl.common.room.entity.BlastRecordEntity

@Dao
interface BlastRecordDao {

    @Transaction
    @Insert(onConflict= OnConflictStrategy.REPLACE )
    fun insert(vararg entity: BlastRecordEntity)

    @Transaction
    @Delete
    fun delete(vararg entity: BlastRecordEntity)

    @Transaction
    @Update
    fun update(vararg entity: BlastRecordEntity)

    @Transaction
    @Query("select * from blastRecord order by blastKey desc")
    fun query() : List<BlastRecordEntity>

    @Transaction
    @Query("select * from blastRecord where isUpload == 0 order by blastKey desc")
    fun queryUnLoad() : List<BlastRecordEntity>


    @Transaction
    @Query("SELECT * FROM blastRecord WHERE blastKey > (:pageSize)*(:p) limit (:pageSize)")
    fun queryPage(p:Int,pageSize:Int) : List<BlastRecordEntity>


    @Transaction
    @Query("select count(*) from blastRecord")
    fun count() : Int
}